
$(document).ready(function() {
	$("#dutyinfo").jqGrid({
		url : global_url+global_urijs+'schooldut_search_admin'+global_suffix+"?sid="+global_sid,
		datatype : "json",
		mtype : 'GET',
		height:'300',
		width:'770',  
		colNames : [ '姓名', '账号', '职务','开始时间','结束时间','移除','值班编号' ],
		colModel : [ {name : 'teacherName',index : 'teacherName',width : 80,align:'center'}, 
		{name : 'tAccount',index : 'tAccount',width : 80,align:'center'}, 
		{name : 'typeName',index : 'typeName',width : 80,sortable : false,align:'center'},
	    {name : 'sdate_str',index : 'sdate_str',width : 120,sortable : false,align:'center'}, 
	    {name : 'edate_str',index : 'edate_str',width : 120,sortable : false,align:'center'}, 
	    //{name : 'dmOperate',index : 'dmOperate',width : 80,sortable : false}, '修改'
	    {name : 'remove',index : 'remove',width : 80,sortable : false,align:'center'}, 
	    {name : 'did',index:'did',hidden:true},
	    ],
		//autowidth:true,
		jsonReader : {
			root : "stDutys",
			page : "page",
			total : "page_count",
			repeatitems : false
		},
		pager : jQuery("#dutypage"),
		prmNames : {
			page : "page",
			sort : "sort"
		},
		rowNum : 10,
		//rowList: [10, 20, 30],
		sortname : 'teacherName',
		hidegrid : false,
		sortorder : 'asc',
		viewrecords : true,
		caption : '值班信息',
		gridComplete : function() {
			var ids = jQuery("#dutyinfo")
					.jqGrid('getDataIDs');
			for ( var i = 0; i < ids.length; i++) {
				var id = ids[i];
				//up = "<a href='javascript:;' style='color:#f60' onclick='upTel("+ id + ")'>修改</a>";dmOperate : up,
				del = "<a href='javascript:;'  class='jqtrow' onclick='delTel(" + id + ")'>撤销</a>"; 
				jQuery("#dutyinfo").jqGrid('setRowData',ids[i], {remove:del});
			}
		}
	}).navGrid("#dutypage", {edit : false,add : false,del : false,search : false});
});

function delTel(id){
	 $("#deltname").html(jQuery("#dutyinfo").jqGrid('getRowData', id).teacherName+":"+jQuery("#dutyinfo").jqGrid('getRowData', id).sdate_str+"至"+jQuery("#dutyinfo").jqGrid('getRowData', id).edate_str);
	 $(function() {
			$( "#duty_del" ).dialog({
				modal: true,
				resizable: false,
				buttons: {
					"移出": function() {
						var funadd = function(data1){
							if(1==data1.s){
								 $().message("移出成功!");
								 $("#dutyinfo").trigger("reloadGrid");
								 $("#duty_del").dialog( "close" );
							}else{
								 $().message("移出失败!");
							}
						};
						exeAjax(ajaxUrl(global_url+global_urijs+'schooldut_delete'+global_suffix+"?sid="+global_sid), funadd, {"did" :jQuery("#dutyinfo").jqGrid('getRowData', id).did});
					},"取消": function() {
						$( this ).dialog( "close" );
					}
				}
			});
		});
}